﻿Imports System.Windows.Forms

Public Class RelationshipDialog

    Public Sub LoadLABox()
        Dim sql As String



        sql = "select LA_Code, LA_Name from Local_Authorities la inner join TerritoryJoin t on (t.Region_Code = la.Region_Code and t.Territory_Code = '" & TerritoryBox.SelectedValue.ToString & "') order by la.LA_Name"

        LABox.DataSource = LoadDataView(sql)
        LABox.DisplayMember = "LA_Name"
        LABox.ValueMember = "LA_Code"
        LABox.Refresh()
    End Sub

    Public Sub LoadTerritoryBox()
        LoadComboBox(TerritoryBox, "select * from Territories order by Territory_name", "Territory_Code", "Territory_name")
    End Sub

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click

        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub



    Private Sub TerritoryBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TerritoryBox.SelectedIndexChanged
        LoadLABox()

    End Sub

    Private Sub RelationshipDialog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '   LoadTerritoryBox()

    End Sub
End Class
